package com.ruoyi.project.site.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.site.domain.BinsSiteInfo;
import com.ruoyi.project.site.service.IBinsSiteInfoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 投放点管理Controller
 * 
 * @author administrator
 * @date 2025-04-03
 */
@RestController
@RequestMapping("/site/info")
public class BinsSiteInfoController extends BaseController
{
    @Autowired
    private IBinsSiteInfoService binsSiteInfoService;

    /**
     * 查询投放点管理列表
     */
    @PreAuthorize("@ss.hasPermi('site:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(BinsSiteInfo binsSiteInfo)
    {
        startPage();
        List<BinsSiteInfo> list = binsSiteInfoService.selectBinsSiteInfoList(binsSiteInfo);
        return getDataTable(list);
    }

    /**
     * 导出投放点管理列表
     */
    @PreAuthorize("@ss.hasPermi('site:info:export')")
    @Log(title = "投放点管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BinsSiteInfo binsSiteInfo)
    {
        List<BinsSiteInfo> list = binsSiteInfoService.selectBinsSiteInfoList(binsSiteInfo);
        ExcelUtil<BinsSiteInfo> util = new ExcelUtil<BinsSiteInfo>(BinsSiteInfo.class);
        util.exportExcel(response, list, "投放点管理数据");
    }

    /**
     * 获取投放点管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('site:info:query')")
    @GetMapping(value = "/{siteId}")
    public AjaxResult getInfo(@PathVariable("siteId") Long siteId)
    {
        return success(binsSiteInfoService.selectBinsSiteInfoBySiteId(siteId));
    }

    /**
     * 新增投放点管理
     */
    @PreAuthorize("@ss.hasPermi('site:info:add')")
    @Log(title = "投放点管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BinsSiteInfo binsSiteInfo)
    {
        return toAjax(binsSiteInfoService.insertBinsSiteInfo(binsSiteInfo));
    }

    /**
     * 修改投放点管理
     */
    @PreAuthorize("@ss.hasPermi('site:info:edit')")
    @Log(title = "投放点管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BinsSiteInfo binsSiteInfo)
    {
        return toAjax(binsSiteInfoService.updateBinsSiteInfo(binsSiteInfo));
    }

    /**
     * 删除投放点管理
     */
    @PreAuthorize("@ss.hasPermi('site:info:remove')")
    @Log(title = "投放点管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{siteIds}")
    public AjaxResult remove(@PathVariable Long[] siteIds)
    {
        return toAjax(binsSiteInfoService.deleteBinsSiteInfoBySiteIds(siteIds));
    }
}
